#include <stdio.h>

#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

int main() {
  int n, m;
  ll A[1000 + 5];

  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &A[i]);
  }
  sort(A, A + n, greater<ll>());
  ll ans = 0;
  for (int i = 0; i < m; ++i) {
    ans += A[i];
  }
  printf("%lld\n", ans);
  return 0;
}